package com.pretty.test.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.pretty.test.controller.pets.blog.wrapper.BlogPageWrapper;
import com.pretty.test.controller.system.menu.dto.MenuListDTO;
import com.pretty.test.controller.system.menu.vo.MenuListVO;
import com.pretty.test.controller.system.menu.wrapper.MenuListWrapper;
import com.pretty.test.entity.PetsMenu;
import com.pretty.test.mapper.PetsMenuMapper;
import com.pretty.test.service.IPetsMenuService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pretty.test.utils.otherutils.Func;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 系统菜单服务实现类
 * @author dujianyu
 * @since 2021-04-09
 */
@Service
public class PetsMenuServiceImpl extends ServiceImpl<PetsMenuMapper, PetsMenu> implements IPetsMenuService {

    @Override
    public List<MenuListVO> selectMenuList( MenuListDTO dto) {
        QueryWrapper queryWrapper  = new QueryWrapper();
        if(dto.getIsParent() == 1){
            queryWrapper.eq("parent_id",0);
        }
        queryWrapper.eq("is_deleted",0);
        queryWrapper.like(!Func.isBlank(dto.getText()),"text",dto.getText());
        queryWrapper.like(!Func.isBlank(dto.getLink()),"link",dto.getLink());
        queryWrapper.orderByAsc("sort");
        return MenuListWrapper.build().listVO(baseMapper.selectList(queryWrapper));
    }
}
